//
//  GYLockListHeadView.m
//  LockManagement
//
//  Created by apple on 2018/7/27.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

static NSString *LockListHeadViewIdentifier = @"LockListHeadViewIdentifier";

#import "GYLockListHeadView.h"

@interface GYLockListHeadView()

@property (weak, nonatomic) IBOutlet UIImageView *directionImageView;
@property (weak, nonatomic) IBOutlet UILabel *lockNameLable;
@property (weak, nonatomic) IBOutlet UILabel *lockStateLable;

@end

@implementation GYLockListHeadView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = [UIColor whiteColor];
}

+ (instancetype)headViewWithTableView:(UITableView *)tableView {
    GYLockListHeadView *headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:LockListHeadViewIdentifier];
    
    if (headView == nil) {
        headView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
    }
    
    return headView;
}

- (IBAction)onClick:(UIButton *)sender {
    self.headViewBtnClickCallBack(self.model);
}

- (void)setModel:(GYLock *)model {
    _model = model;
    
    self.lockNameLable.text = model.lockName;
    self.lockStateLable.text = model.lockState ? @"已编码" : @"未编码";
}

- (void)setOpen:(BOOL)open {
    _open = open;
    
    self.directionImageView.image = [UIImage imageNamed:open ? @"more1" : @"more"];
}



@end
